package com.demo.liugui.controller;

import com.demo.liugui.annotation.Decrypt;
import com.demo.liugui.annotation.Encrypt;
import com.demo.liugui.bean.RespBean;
import com.demo.liugui.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: UserController
 * @Author: liugui
 * @Date: 2021-10-27 15:20
 **/
@RestController
public class UserController {

    @GetMapping("/user")
    @Encrypt
    public RespBean getUser(){
        User user = new User();
        user.setAge(99);
        user.setName("liugui");
        return RespBean.ok("ok", user);
    }

    @PostMapping("/user")
    public RespBean addUser(@RequestBody @Decrypt User user){
        System.out.println("user = " + user);
        return RespBean.ok("ok", user);
    }
}
